/*
 Promise 处理异步
 resolve 成功的回调函数
 reject  失败的回调函数
 */

var p = new Promise(function(resolve,reject){
	setTimeout(function(){
// 		var name = 'zhansan'
// 		resolve(name);
		var name = Math.random()
		if(name<0.5){
			resolve(name)
		}else{
			reject(`失败了，${name}大于0.5`)
		}
	},1000)
})

p.then((data)=>{
	console.log(data)
})
.catch((data)=>{
	console.log(data)
})